<?php
include_once 'crypt3des.php';
class Cookie
{
    public static $path='/';
    private static $iv='www.rsseasy.com';
    public static function Set($key,$value,$expire=0)
    {
        setcookie($key,$value,$expire,Cookie::$path,cookiedomain);
    }
    public static function Get($key)
    {
        $value=$_COOKIE[$key];
        return empty($value)?'':$value;
    }
    public static function EncryptSet($key,$value,$expire=0)
    {
        $rsseasy=Cookie::Get('cryptrsseasy');
        if(empty($rsseasy))
        {
            $rsseasy='{}';
        }
        $rsseasy=json_decode($rsseasy,TRUE);
        $rsseasy[$key]=$value;
        $rsseasy=json_encode($rsseasy);

        $cryptr=new Crypt3Des(prikey,Cookie::$iv);
        $rsseasy=$cryptr->encrypt($rsseasy);

        setcookie('cryptrsseasy',$rsseasy,$expire,Cookie::$path,cookiedomain);
    }
    public static function DecryptGet($key)
    {
        $rsseasy=Cookie::Get('cryptrsseasy');
        if(empty($rsseasy))
        {
            $rsseasy='{}';
        }
        $crypt=new Crypt3Des(prikey,Cookie::$iv);
        $rsseasy=$crypt->decrypt($rsseasy);
        $json=json_decode($rsseasy,TRUE);
        return $json[$key];
    }
}
?>